cc.Class({
    extends: cc.Component,

    properties: {

    },

    init(blockScene) {
        this.blockScene = blockScene;
    },
    on_touch_move: function(t) {
        // 位置
        // console.log("cc.Node.EventType.TOUCH_MOVE called");
        // console.log(t.getLocation());
        var w_pos = t.getLocation(); // cc.Vec2 {x, y}
        // console.log(w_pos, w_pos.x, w_pos.y);

        // 距离上一次触摸变化了多少;
        var delta = t.getDelta(); // x, y各变化了多少cc.Vec2(x, y)

        this.node.x += delta.x * 2;
        this.node.y += delta.y * 2;
        var width = cc.view.getFrameSize().width / 2;
        var height = cc.view.getFrameSize().height / 2;
        if (this.node.x <= -360) {
            this.node.x = -360;
        }
        if (this.node.x >= 360) {
            this.node.x = 360;
        }
        if (this.node.y >= 640) {
            this.node.y = 640;
        }
        if (this.node.y <= -640) {
            this.node.y = -640;
        }
    },

    onBeginContact(contact, self, other) {
        // console.log("onBeginContact------", other.tag);
        switch (other.tag) {
            case 2: //球碰到障碍物
                // this.brickScene.onBallContactBrick(self.node, other.node);
                this.blockScene.addScore();
                break;
        }
    },

    // use this for initialization
    onLoad: function() {
        this.node.parent.on(cc.Node.EventType.TOUCH_MOVE, this.on_touch_move, this);
    },

    start() {

    },

    update(dt) {},
});